<template>
  <view :style="themeColor">
    <view class="page">
      <fu-custom bgColor="bg-white" :isBack="true" :isBottom="true">
        <block slot="content">绑定银行卡</block>
      </fu-custom>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindBankCard_flex_1">
        <view class='flex flex-direction align-stretch bindBankCard_fd1_0'>
          <view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
            <text class='bindBankCard_fd1_0_c0_c0'>持卡人姓名</text>
            <input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入真实姓名`" confirm-type="done"
              :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
              v-model="dataBangding.real_name" />
          </view>
          <view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
            <text class='bindBankCard_fd1_0_c0_c0'>银行名称</text>
            <input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入银行名称`" confirm-type="done"
              :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
              v-model="dataBangding.bank_name" />
          </view>
          <view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
            <text class='bindBankCard_fd1_0_c0_c0'>银行卡号</text>
            <input class='flex-sub bindBankCard_fd1_0_c0_c1' type="number" :placeholder="`请输入银行卡号`" confirm-type="done"
              :maxlength="19" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
              v-model="dataBangding.account" />
          </view>
          <view class='flex flex-wrap align-center bindBankCard_fd1_0_c0'>
            <text class='bindBankCard_fd1_0_c0_c0'>开户行</text>
            <input class='flex-sub bindBankCard_fd1_0_c0_c1' type="text" :placeholder="`请输入开户行`" confirm-type="done"
              :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
              v-model="dataBangding.bank_address" />
          </view>
        </view>
        <view class='flex flex-wrap align-center justify-center bindBankCard_fd1_1'>
          <button class='bindBankCard_fd1_1_c0' @tap.stop="postBankFunc()">提交</button>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "real_name": "",
        "bank_name": "",
        "bank_address": "",
        "account": "",
        "dataDetails": {
          "invite_code": "",
          "address": "",
          "address_code": "",
          "hobby": "",
          "tags": "",
          "id": "",
          "userlevel_id": "",
          "mobile": "",
          "real_name": "",
          "avatar": "",
          "account": "",
          "email": "",
          "birthday": "",
          "gender": "",
          "create_time": "",
          "user_money": "",
          "freeze_money": "",
          "total_consumption_money": "",
          "score": "",
          "_mobile": "",
          "coupon": "",
          "collection_count": "",
          "browse_count": "",
          "total_money": "",
          "certified": "",
          "nickname": "",
          "is_pay_password": "",
          "follow_count": ""
        },
        "qrcode_url": "",
        "dataBangding": {
          "aid": "",
          "is_default": "",
          "create_time": "",
          "update_time": "",
          "status": "",
          "real_name": "",
          "account": "",
          "qrcode_url": "",
          "bank_name": "",
          "bank_address": "",
          "remark": ""
        },
        "type": "1"
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        type
      } = options
      if (type !== undefined) this.type = type
      this.getbangdingFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //绑定银行卡
      async postBankFunc() {
        if (!validate(this.dataBangding.real_name, 'require')) {
          this.$message.info('请输入真实姓名');
          return false;
        }
        if (!validate(this.dataBangding.bank_name, 'require')) {
          this.$message.info('请输入银行名称');
          return false;
        }
        if (!validate(this.dataBangding.account, 'require')) {
          this.$message.info('请输入银行卡号');
          return false;
        }
        if (!validate(this.dataBangding.account, 'card')) {
          this.$message.info('请输入正确的银行卡');
          return false;
        }
        if (!validate(this.dataBangding.bank_address, 'require')) {
          this.$message.info('请输入开户行');
          return false;
        }
        //请求方法
        //数据验证

        let data636cc0cc8d6cc = await this.$api.post(global.apiUrls.post636cc0cc8d6cc, {
          real_name: this.dataBangding.real_name,
          account_type: 'bank',
          account: this.dataBangding.account,
          bank_name: this.dataBangding.bank_name,
          bank_address: this.dataBangding.bank_address
        });

        if (data636cc0cc8d6cc.data.code != 1) {
          this.$message.info(data636cc0cc8d6cc.data.msg);
          return
        }



        this.$message.info('银行卡绑定成功');
        setTimeout(() => {
          this.$urouter.navigateBack(1);
        }, 500)
      },
      //获取绑定信息
      async getbangdingFunc() {
        if (this.type == '1') {
          //请求方法
          //数据验证

          let datadataBangding = await this.$api.get(global.apiUrls.post636cbb376d5d8, {
            account_type: 'bank'
          });

          if (datadataBangding.data.code != 1) {
            this.$message.info(datadataBangding.data.msg);
            return
          }
          let infodataBangding = datadataBangding.data;
          this.dataBangding = infodataBangding.data

        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: #F8F8F8;
    background-size: 100% auto;
  }

  .bindBankCard_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .bindBankCard_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
  }

  .bindBankCard_fd0_0_c0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333;
  }

  .bindBankCard_fd0_0_c0 {
    width: 180rpx;
  }

  .bindBankCard_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
  }

  .bindBankCard_flex_1 {
    padding: 0rpx 0rpx 150rpx 0rpx;
  }

  .bindBankCard_fd1_1_c0 {
    background: var(--benbenbgColor7);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    font-size: 32rpx;
    color: #fff;
    width: 686rpx;
    height: 80rpx;
    line-height: 80rpx;
    font-weight: 700;
  }

  .bindBankCard_fd1_1 {
    width: 750rpx;
    position: fixed;
    left: 0rpx;
    bottom: calc(40rpx + var(--window-bottom));
  }

  .bindBankCard_fd1_0_c0_c1 {
    font-size: 32rpx;
    font-weight: 400;
    color: #333;
  }

  .bindBankCard_fd1_0_c0_c0 {
    width: 210rpx;
    line-height: 43rpx;
    font-size: 32rpx;
    font-weight: 400;
    color: #333333;
  }

  .bindBankCard_fd1_0_c0 {
    border-bottom: 1px solid #eee;
    height: 109rpx;
  }

  .bindBankCard_fd1_0 {
    background: var(--benbenbgColor1);
    padding: 0rpx 32rpx 0rpx 32rpx;
    background-size: 100% auto !important;
  }
</style>